package com.java1412;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author java1412
 * @since 2023-02-20 10:52
 */
@SpringBootApplication
@EnableEurekaClient // 作为eureka的客户端
@EnableDiscoveryClient // 作为服务发现的客户端
@EnableHystrix  // 开启断路器的功能
public class ServiceRibbon8764Application {
    public static void main(String[] args) {
        SpringApplication.run(ServiceRibbon8764Application.class, args);
    }

    // 向IOC容器注册rest模板
    @Bean // 表示向IOC容器注册
    @LoadBalanced // 开启restTemplate的负载均衡功能
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
